<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: FileColumnHelpers</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">FileColumnHelpers</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/file_column_helpers_rb.html">
                vendor/plugins/active_scaffold/lib/bridges/file_column/lib/file_column_helpers.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000040">field_has_image_version?</a>&nbsp;&nbsp;
      <a href="#M000035">file_column_fields</a>&nbsp;&nbsp;
      <a href="#M000038">file_column_fields</a>&nbsp;&nbsp;
      <a href="#M000041">generate_delete_helpers</a>&nbsp;&nbsp;
      <a href="#M000036">generate_delete_helpers</a>&nbsp;&nbsp;
      <a href="#M000037">klass_has_file_column_fields?</a>&nbsp;&nbsp;
      <a href="#M000039">options_for_file_column_field</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000035" class="method-detail">
        <a name="M000035"></a>

        <div class="method-heading">
          <a href="#M000035" class="method-signature">
          <span class="method-name">file_column_fields</span><span class="method-args">(klass)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000035-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/bridges/file_column/lib/file_column_helpers.rb, line 3</span>
3:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">file_column_fields</span>(<span class="ruby-identifier">klass</span>)
4:       <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">instance_methods</span>.<span class="ruby-identifier">grep</span>(<span class="ruby-regexp re">/_just_uploaded\?$/</span>).<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span> <span class="ruby-identifier">m</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">-16</span>].<span class="ruby-identifier">to_sym</span> }
5:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000036" class="method-detail">
        <a name="M000036"></a>

        <div class="method-heading">
          <a href="#M000036" class="method-signature">
          <span class="method-name">generate_delete_helpers</span><span class="method-args">(klass)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000036-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/bridges/file_column/lib/file_column_helpers.rb, line 7</span>
 7:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate_delete_helpers</span>(<span class="ruby-identifier">klass</span>)
 8:       <span class="ruby-identifier">file_column_fields</span>(<span class="ruby-identifier">klass</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">field</span><span class="ruby-operator">|</span>
 9:         <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">:class_eval</span>, <span class="ruby-value str">&quot;attr_reader :delete_\#{field}\n\ndef delete_\#{field}=(value)\nvalue = (value==\&quot;true\&quot;) if String===value\nreturn unless value\n\n# passing nil to the file column causes the file to be deleted.  Don't delete if we just uploaded a file!\nself.\#{field} = nil unless self.\#{field}_just_uploaded?\nend\n&quot;</span>, <span class="ruby-keyword kw">__FILE__</span>, <span class="ruby-keyword kw">__LINE__</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>  <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-node">&quot;#{field}_with_delete=&quot;</span>)
10:       }
11:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000037" class="method-detail">
        <a name="M000037"></a>

        <div class="method-heading">
          <a href="#M000037" class="method-signature">
          <span class="method-name">klass_has_file_column_fields?</span><span class="method-args">(klass)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000037-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/bridges/file_column/lib/file_column_helpers.rb, line 24</span>
24:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">klass_has_file_column_fields?</span>(<span class="ruby-identifier">klass</span>)
25:       <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">file_column_fields</span>(<span class="ruby-identifier">klass</span>).<span class="ruby-identifier">empty?</span>
26:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000040" class="method-detail">
        <a name="M000040"></a>

        <div class="method-heading">
          <a href="#M000040" class="method-signature">
          <span class="method-name">field_has_image_version?</span><span class="method-args">(field, version=&quot;thumb&quot;)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000040-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/bridges/file_column/lib/file_column_helpers.rb, line 37</span>
37:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">field_has_image_version?</span>(<span class="ruby-identifier">field</span>, <span class="ruby-identifier">version</span>=<span class="ruby-value str">&quot;thumb&quot;</span>)
38:     <span class="ruby-keyword kw">begin</span>
39:       <span class="ruby-comment cmt"># the only way to get to the options of a particular field is to use the instance method</span>
40:       <span class="ruby-identifier">options</span> = <span class="ruby-identifier">options_for_file_column_field</span>(<span class="ruby-identifier">field</span>)
41:       <span class="ruby-identifier">versions</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:magick</span>][<span class="ruby-identifier">:versions</span>]
42:       <span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">versions</span>.<span class="ruby-identifier">stringify_keys</span>[<span class="ruby-identifier">version</span>]
43:       <span class="ruby-keyword kw">true</span>
44:     <span class="ruby-keyword kw">rescue</span>
45:       <span class="ruby-keyword kw">false</span>
46:     <span class="ruby-keyword kw">end</span>
47:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000038" class="method-detail">
        <a name="M000038"></a>

        <div class="method-heading">
          <a href="#M000038" class="method-signature">
          <span class="method-name">file_column_fields</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000038-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/bridges/file_column/lib/file_column_helpers.rb, line 29</span>
29:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">file_column_fields</span>
30:     <span class="ruby-ivar">@file_column_fields</span><span class="ruby-operator">||=</span><span class="ruby-constant">FileColumnHelpers</span>.<span class="ruby-identifier">file_column_fields</span>(<span class="ruby-keyword kw">self</span>)
31:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000041" class="method-detail">
        <a name="M000041"></a>

        <div class="method-heading">
          <a href="#M000041" class="method-signature">
          <span class="method-name">generate_delete_helpers</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000041-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/bridges/file_column/lib/file_column_helpers.rb, line 49</span>
49:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate_delete_helpers</span>
50:     <span class="ruby-constant">FileColumnHelpers</span>.<span class="ruby-identifier">generate_delete_helpers</span>(<span class="ruby-keyword kw">self</span>)
51:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000039" class="method-detail">
        <a name="M000039"></a>

        <div class="method-heading">
          <a href="#M000039" class="method-signature">
          <span class="method-name">options_for_file_column_field</span><span class="method-args">(field)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000039-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/bridges/file_column/lib/file_column_helpers.rb, line 33</span>
33:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options_for_file_column_field</span>(<span class="ruby-identifier">field</span>)
34:     <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">allocate</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{field}_options&quot;</span>)
35:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>